(function(e){"use strict";BX.namespace("BX.Landing.SliderHelper");BX.Landing.SliderHelper.ACTION_INIT="init";BX.Landing.SliderHelper.ACTION_ADD="add";BX.Landing.SliderHelper.ACTION_REMOVE_SLIDE="remove_slide";BX.Landing.SliderHelper.ACTION_UPDATE="update";BX.Landing.SliderHelper.CAROUSEL_CLASS="js-carousel";BX.Landing.SliderHelper.ACTIVE_CLASS="slick-initialized";BX.Landing.SliderHelper.editorEnableFlag=false;BX.Landing.SliderHelper.init=function(e,r){r=r?r:BX.Landing.SliderHelper.ACTION_INIT;const i=BX.Landing.SliderHelper.makeCarouselRelativeSelector(e);const a=[].slice.call(e.block.querySelectorAll(i));a.forEach((function(i){BX.Landing.SliderHelper.applySettings(i,e.data);if(BX.Landing.SliderHelper.isSliderActive(i)&&r===BX.Landing.SliderHelper.ACTION_UPDATE){BX.Landing.SliderHelper.destroy(e)}BX.Landing.SliderHelper.initBase(i);if(r===BX.Landing.SliderHelper.ACTION_UPDATE||r===BX.Landing.SliderHelper.ACTION_ADD||r===BX.Landing.SliderHelper.ACTION_REMOVE_SLIDE){BX.Landing.SliderHelper.goToSlide(i,e,r);BX.Landing.SliderHelper.setSelection(e)}}))};BX.Landing.SliderHelper.destroy=function(r){const i=BX.Landing.SliderHelper.makeCarouselRelativeSelector(r);const a=[].slice.call(r.block.querySelectorAll(i));a.forEach((function(r){if(BX.Landing.SliderHelper.isSliderActive(r)){r.slickCurrentSlide=e(r).slick("slickCurrentSlide");e(r).slick("unslick")}}));BX.Landing.SliderHelper.saveSelection(r)};BX.Landing.SliderHelper.initBase=function(r){const i=e(r).data("init-classes-exclude");if(i&&BX.type.isArray(i)){i.forEach((function(i){if(i.selector&&i.class){e(r).parent().find(i.selector).removeClass(i.class)}}))}let a={accessibility:false};if(BX.Landing.getMode()==="edit"){a.infinite=false}e.HSCore.components.HSCarousel.init(r,a)};BX.Landing.SliderHelper.makeCarouselRelativeSelector=function(e,r){r=r||BX.Landing.SliderHelper.CAROUSEL_CLASS;let i=[];if(e.block){let a=[];if(e.card){a=e.block.querySelectorAll("."+e.card.className.split(/\s+/).join("."))}else if(e.node){a=[e.node]}else if(e.data&&e.data.selector){a=e.block.querySelectorAll(e.data.selector.split("@")[0])}a.forEach((function(e){let a=BX.findParent(e,{className:r}),t="";if(a){a.classList.forEach((function(e){if(e.indexOf("slick-")===-1){t+="."+e}}));if(i[i.length-1]!==t){i.push(t)}}}))}if(i.length===0){i=["."+r]}i.forEach((function(r,a){i[a]=e.makeRelativeSelector(r)}));return i.join(",")};BX.Landing.SliderHelper.isSliderActive=function(e){if(!BX.Type.isArrayLike(e)){e=[e]}let r=false;e.forEach((function(e){if(BX.hasClass(e,BX.Landing.SliderHelper.ACTIVE_CLASS)){r=true}}));return r};BX.Landing.SliderHelper.saveSelection=function(e){if(window.getSelection().rangeCount>0){var r=window.getSelection().getRangeAt(0);e.block.savedRange={sCont:r.startContainer,sOffset:r.startOffset,eCont:r.endContainer,eOffset:r.endOffset}}};BX.Landing.SliderHelper.setSelection=function(e){let r=e.block.savedRange;if(r){let e=document.createRange();e.setStart(r.sCont,r.sOffset);e.setEnd(r.eCont,r.eOffset);let i=window.getSelection();i.removeAllRanges();i.addRange(e)}};BX.Landing.SliderHelper.goToSlide=function(e,r,i){if(!i){return}var a=parseInt(e.slickCurrentSlide);var t=i===BX.Landing.SliderHelper.ACTION_REMOVE_SLIDE?BX.Landing.SliderHelper.findNewSlideWhenRemove(r):r.card;if(e.dataset.rows&&parseInt(e.dataset.rows)>1){t=BX.findParent(r.card,{className:"slick-slide"})}if(t){var l=parseInt(t.dataset.slickIndex)}switch(i){case BX.Landing.SliderHelper.ACTION_ADD:BX.Landing.SliderHelper.goToSlideAfterAdd(e,a,l);break;case BX.Landing.SliderHelper.ACTION_REMOVE_SLIDE:BX.Landing.SliderHelper.goToSlideAfterRemove(e,a,l);break;case BX.Landing.SliderHelper.ACTION_UPDATE:BX.Landing.SliderHelper.goToSlideAfterUpdate(e,a);break;default:}};BX.Landing.SliderHelper.findNewSlideWhenRemove=function(e){var r=e.data.selector,i=r.split("@")[0],a=parseInt(r.split("@")[1]),t=e.block.querySelectorAll(i);var l=t[a];if(!l){l=!BX.type.isNumber(a)||a===0?null:t[a-1]}return l};BX.Landing.SliderHelper.goToSlideAfterAdd=function(r,i,a){if(BX.type.isNumber(a)&&BX.type.isNumber(i)){var t=e(r).slick("slickGetOption","slidesToShow");t=t===true?1:t;if(a-i>=t){e(r).slick("slickGoTo",i,true);e(r).slick("slickGoTo",i+1,false)}else{e(r).slick("slickGoTo",i,true)}}};BX.Landing.SliderHelper.goToSlideAfterRemove=function(r,i,a){if(BX.type.isNumber(a)&&BX.type.isNumber(i)){e(r).slick("slickGoTo",Math.min(i,a),true)}};BX.Landing.SliderHelper.goToSlideAfterUpdate=function(r,i){if(BX.type.isNumber(i)){e(r).slick("slickGoTo",i,true)}};BX.Landing.SliderHelper.setEditorEnable=function(e){BX.Landing.SliderHelper.editorEnableFlag=!!e};BX.Landing.SliderHelper.isEditorEnable=function(){return!!BX.Landing.SliderHelper.editorEnableFlag};BX.Landing.SliderHelper.applySettings=function(e){BX.Landing.SliderHelper.setAutoplay(e);BX.Landing.SliderHelper.setAutoplaySpeed(e);BX.Landing.SliderHelper.setPauseOnHover(e);BX.Landing.SliderHelper.setAnimation(e);BX.Landing.SliderHelper.setAmountSlidesShow(e);BX.Landing.SliderHelper.setArrows(e);BX.Landing.SliderHelper.setDotsVisible(e)};BX.Landing.SliderHelper.setAutoplay=function(e){if(BX.Dom.attr(e.parentNode,"data-slider-autoplay")===0){BX.Dom.attr(e,"data-autoplay",false)}if(BX.Dom.attr(e.parentNode,"data-slider-autoplay")===1){BX.Dom.attr(e,"data-autoplay",true)}};BX.Landing.SliderHelper.setAutoplaySpeed=function(e){if(BX.Type.isInteger(BX.Dom.attr(e.parentNode,"data-slider-autoplay-speed"))){BX.Dom.attr(e,"data-speed",BX.Dom.attr(e.parentNode,"data-slider-autoplay-speed"))}};BX.Landing.SliderHelper.setDotsVisible=function(e){var r=BX.Dom.attr(e,"data-slick");if(!BX.Type.isObject(r)){r={}}if(BX.Dom.attr(e.parentNode,"data-slider-dots")===0){r.dots=false;BX.Dom.attr(e,"data-slick",r)}if(BX.Dom.attr(e.parentNode,"data-slider-dots")===1){r.dots=true;BX.Dom.attr(e,"data-slick",r)}};BX.Landing.SliderHelper.setPauseOnHover=function(e){if(BX.Type.isBoolean(BX.Dom.attr(e.parentNode,"data-slider-pause-hover"))){BX.Dom.attr(e,"data-pause-hover",BX.Dom.attr(e.parentNode,"data-slider-pause-hover"))}};BX.Landing.SliderHelper.setAmountSlidesShow=function(e){if(BX.Type.isInteger(BX.Dom.attr(e.parentNode,"data-slider-slides-show"))){BX.Dom.attr(e,"data-slides-show",BX.Dom.attr(e.parentNode,"data-slider-slides-show"))}};BX.Landing.SliderHelper.setArrows=function(e){var r=BX.Dom.attr(e,"data-slick");if(!BX.Type.isObject(r)){r={}}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===0){r.arrows=false;BX.Dom.attr(e,"data-slick",r)}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")>0){r.arrows=true;BX.Dom.attr(e,"data-slick",r);var i=["g-color-white","g-color-gray","g-color-gray-light-v1","g-color-primary--hover","g-color-white--hover","g-bg-primary","g-bg-gray-light-v2","g-bg-gray-light-v5","g-bg-primary--hover","g-rounded-50x","g-opacity-0_8--hover","g-bg-gray-light-v3"];var a=BX.Dom.attr(e,"data-arrows-classes");var t=a.split(" ");i.forEach((function(e){if(t.includes(e)){var r=t.indexOf(e);t.splice(r,1)}}));var l=[];if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===1){l=["g-color-gray","g-color-white--hover","g-bg-gray-light-v5","g-bg-primary--hover"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===2){l=["g-color-gray","g-color-white--hover","g-bg-gray-light-v5","g-bg-primary--hover","g-rounded-50x"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===3){l=["g-color-white","g-bg-primary","g-opacity-0_8--hover"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===4){l=["g-color-white","g-bg-primary","g-opacity-0_8--hover","g-rounded-50x"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===5){l=["g-color-white","g-bg-gray-light-v2","g-bg-primary--hover"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===6){l=["g-color-white","g-bg-gray-light-v2","g-bg-primary--hover","g-rounded-50x"]}if(BX.Dom.attr(e.parentNode,"data-slider-arrows")===7){l=["g-color-gray-light-v1","g-color-primary--hover"]}l.forEach((function(e){t.push(e)}));a=t.join(" ");BX.Dom.attr(e,"data-arrows-classes",a)}};BX.Landing.SliderHelper.setAnimation=function(e){var r=BX.Dom.attr(e,"data-slick");if(!BX.Type.isObject(r)){r={}}if(BX.Dom.attr(e.parentNode,"data-slider-animation")===0){r.animation="none"}if(BX.Dom.attr(e.parentNode,"data-slider-animation")===1){r.animation="ease"}if(BX.Dom.attr(e.parentNode,"data-slider-animation")===2){r.animation="cubic-bezier(0.600, -0.280, 0.735, 0.045)"}if(BX.Dom.attr(e.parentNode,"data-slider-animation")===3){r.animation="";BX.Dom.attr(e,"data-fade","true")}else{if(BX.Dom.attr(e.parentNode,"data-slider-animation")!==null){e.removeAttribute("data-fade")}}BX.Dom.attr(e,"data-slick",r)}})(window.jQueryLanding||jQuery);
//# sourceMappingURL=carousel_helper.map.js